package com.hyr.springcloud.user.dao;

import com.hyr.springcloud.user.domain.UserInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.math.BigDecimal;

public interface UserInfoRepository extends JpaRepository<UserInfo, Integer> {

    UserInfo findByUsername(String username);

    @Modifying
    @Query("update userinfo set balance = balance- ?2 where id=?1")
    int charge(Integer userinfoId, BigDecimal amount);
}
